Number of Salads
Submit your assignment
Receive grade
To Pass100% or higher
Grade
100%
We keep your highest score
We have an unlimited supply of tomatoes, bell peppers and lettuce. We want to make a salad out of 4 units among these three ingredients (we do not have to use all ingredients). The order in which we use the ingredients does not matter. How many different salads we can make?
We do not have the formula to answer this question yet, so try to list all the salads first or create a program that will do that for you. Then you can count the number of salads by hand (note the answer to the problem should be the number).
This is correct!
Here is the code that lists all salads (T=tomato, B=bell pepper, L=lettuce)
1234from itertools import combinations_with_replacementfor c in combinations_with_replacement("TBL", 4):print("".join(c))Enter to Rename, ⇧Enter to Preview
See the next video for discussion.